package com.atguigu.gulimall.product.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author ShiJieLin
 * @Date 2022/4/13 22:48
 * @Version 1.0
 */
@Configuration
public class MyRedissonConfig {

    @Bean(destroyMethod = "shutdown")
    public RedissonClient redissonClient(){
        // 1.创建配置类
        Config config = new Config();
        // 2.根据Config创建出RedissonClient实例
        config.useSingleServer().setAddress("redis://192.168.42.150:6379");

        RedissonClient redissonClient = Redisson.create(config);

        return redissonClient;

    }
}
